//
//  ViewController.m
//  MultiSegmentControl
//
//  Created by ET|冰琳 on 16/7/1.
//  Copyright © 2016年 Ice Butterfly. All rights reserved.
//

#import "ViewController.h"
#import "BIMultiSegmentControl.h"

@interface ViewController ()

@property (nonatomic, strong) IBOutlet NSMutableArray *viewControllers;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
//    self.navigationController.navigationBar.translucent = NO;
    // Do any additional setup after loading the view, typically from a nib.
    self.viewControllers = [NSMutableArray new];
    [self.viewControllers addObject:@"SegmentController"];
    [self.viewControllers addObject:@"SegmentDropContainerController"];
    [self.viewControllers addObject:@"ExampleColoredSegController"];
    [self.viewControllers addObject:@"ExampleColoredNaviController"];
    
    BIMultiSegmentControl *multi = [[EqualWSegmentControl alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width/3*2, 44.f) titles:@[@"社区",@"福利",@"活动"]];
    self.navigationItem.titleView = multi;

}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.viewControllers.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    }
    cell.textLabel.text = self.viewControllers[indexPath.row];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    NSString *vcName = self.viewControllers[indexPath.row];
    UIViewController *vc = [[NSClassFromString(vcName) alloc] init];
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
